package com.test.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.test.domain.User;
import com.test.mapper.UserMapper;
import com.test.service.UserService;


@Service
public class UserServiceImpl  implements UserService{

	   //因为主类的@MapperScan方法，所以自动为UserMapper装配了一个userMapper对象
    @Autowired
    private UserMapper userMapper;
    
    //这里你传过去的时候user的id为null,而insert之后传回回来的user会把数据库中的id值带回来，真强大
   @Override
   public int add(User user) {
       userMapper.insert(user);
       int id = user.getId();
       return id;
   }   
}
